mod spider;

use aruspider::{ConsolePipeline, CsvPipeline, Engine};
use log::info;
use log4rs;
use spider::MovieSpider;
use std::sync::Arc;

use std::time::Instant;

#[tokio::main]
async fn main() {
    let now = Instant::now();
    log4rs::init_file("config/log4rs.yml", Default::default()).unwrap();
    let spider = MovieSpider {
        // start_urls: vec!["https://ssr1.scrape.center/"],
        start_urls: vec!["https://ssr4.scrape.center/"],
    };
    let mut engine = Engine::builder()
        .max(4)
        .spider(Arc::new(spider))
        // .add_pipeline(Box::new(CsvPipeline::new("data/output.csv")))
        .add_pipeline(Box::new(ConsolePipeline))
        .build();
    engine.run().await;
    info!("爬取完成, 耗时 {} 秒", now.elapsed().as_secs());
}
